import java.util.Arrays;

class Solution {
    public void rotate(int[] nums, int k) {
        int n = nums.length;
        k %= n;
        int t = 0;
        for(int i = 0; i < n / 2; i++){
            t = nums[i];
            nums[i] = nums[n - 1 - i];
            nums[n - 1 - i] = t;
        }
        for(int j = 0; j < k / 2; j++){
            t = nums[j];
            nums[j] = nums[k - 1 - j];
            nums[k - 1 - j] = t;
        }
        for(int v = k; v < (n + k) / 2; v++){
            t = nums[v];
            nums[v] = nums[n - 1 - (v - k)];
            nums[n - 1 - (v - k)] = t;
        }
        System.out.println(Arrays.toString(nums));
    }
}
//2.
class Solution {
    public void rotate(int[] nums, int k) {
        int n = nums.length;
        k %= n;
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[(i + k) % n] = nums[i];
        }
        System.out.println(Arrays.toString(array));
    }
}